
import 'package:after_sale_plugin/pages/edit_order/cell/check_vehicle_error_result_item.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:lx_widgets_library/lx_widgets_library.dart';

import '../../models/order_model.dart';

class CheckVehicleErrorItem extends StatelessWidget {
  // 点击事件
  final Function? onTap;

  // 是否高亮
  final RxBool? highlighting;

  // 工单数据
  Rx<ReportOrderInfo> reportOrderInfo = ReportOrderInfo.fromMap({}).obs;

  final RxBool? isShowCheckedResult;

  CheckVehicleErrorItem({
    super.key,
    required this.reportOrderInfo,
    this.onTap,
    this.highlighting,
    this.isShowCheckedResult,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(
        bottom: CONTENT_MARGIN,
      ),
      child: Column(
        children: [
          Container(
            padding: EdgeInsets.all(CONTENT_MARGIN),
            color: const Color(0xFF141414),
            child: Obx(
              () => Column(
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      CommonWidgets.titleText(
                          AppLanguageUtil.to.titleCheckError),
                      InkWell(
                        onTap: () {
                          // 处理点击事件
                          if (onTap != null) {
                            onTap!();
                          }
                        },
                        child: SizedBox(
                          height: 25,
                          child: Center(
                            child: Text(
                              AppLanguageUtil.to.titleStartCheckError,
                              style: TextStyle(
                                decoration: TextDecoration.underline,
                                color: (highlighting?.value == true)
                                    ? const Color(0xFFFF6600)
                                    : const Color(0xFF5C2500),
                                decorationColor: (highlighting?.value == true)
                                    ? const Color(0xFFFF6600)
                                    : const Color(0xFF5C2500),
                              ),
                            ),
                          ),
                        ),
                      )
                    ],
                  ),
                  Visibility(
                    visible: isShowCheckedResult?.value == true,
                    child: CheckVehicleErrorResultItem(
                      reportOrderInfo: reportOrderInfo,
                      maxWidth: screenWidth - 2 * CONTENT_MARGIN,
                    ),
                  )
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}
